import { Form, Input } from "antd";

export default function Index() {
  const validator = (rule, value) => {
    const regex = /^(0[0-9]{1,2}|1[0-7][0-9])$/;
    if (value && value?.length < 3) {
      return Promise.reject(new Error("长度必须为3"));
    } else if (!regex.test(value)) {
      return Promise.reject(new Error("输入为000-179"));
    } else {
      return Promise.resolve();
    }
  };

  return (
    <Form>
      <Form.Item
        name="haha"
        rules={[{ required: true, message: " " }, { validator }]}
      >
        <Input />
      </Form.Item>
    </Form>
  );
}
